/********************************************************************
	created:	2012/02/26   23:31
	filename: 	hy_instance.h
	author:		supercaco@sina.com
	purpose:	boost singleton
*********************************************************************/
#ifndef _HY_INSTANCE_H_
#define _HY_INSTANCE_H_

template <class T>
class singleton : private T
{
private:
	singleton();
	~singleton();

public:
	static T &instance();
};

template <class T>
inline singleton<T>::singleton()
{
	/* no-op */
}

template <class T>
inline singleton<T>::~singleton()
{
	/* no-op */
}

template <class T>
/*static*/ T &singleton<T>::instance()
{
	// function-local static to force this to work correctly at static
	// initialization time.
	static singleton<T> s_oT;
	return(s_oT);
}

#endif
